Skip to content

ui: write wasm RPC requests directly into the tokenizer - #7265

Open
LalitMaganti wants to merge 1 commit into
dev/lalitm/zerocopy-1-ringbufferfrom
dev/lalitm/zerocopy-2-wasm
Open

ui: write wasm RPC requests directly into the tokenizer#7265
LalitMaganti wants to merge 1 commit into
dev/lalitm/zerocopy-1-ringbufferfrom
dev/lalitm/zerocopy-2-wasm

Conversation

@LalitMaganti

@LalitMaganti LalitMaganti commented Aug 28, 2026

Copy link
Copy Markdown
Member

trace_processor_rpc_init() allocated a 32MB request buffer that JS wrote into
and C++ copied out of on every chunk. The tokenizer holds a standing
reservation instead and hands back the address for the next write, so nothing
is copied and it stays at one JS->Wasm call per request.

Entry points are resolved once with cwrap() instead of ccall(), which redoes
the symbol lookup and argument marshalling on every call. For a numeric
signature cwrap() returns the raw wasm export, so this is as direct as it gets:
29.6 ns -> 4.5 ns per call.

memory64, vs the staging buffer: trace load -61.5%, queries -23.7%

addFunction() was declared as returning void; it returns a function pointer.
ccall()'s any[] hid that, cwrap()'s number[] does not.

@LalitMaganti
LalitMaganti requested a review from a team as a code owner August 28, 2026 01:33
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

@stevegolton stevegolton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah, nice!

@LalitMaganti
LalitMaganti force-pushed the dev/lalitm/zerocopy-2-wasm branch from 7fb0dc7 to 1d2e4ed Compare August 28, 2026 15:10
@LalitMaganti
LalitMaganti force-pushed the dev/lalitm/zerocopy-2-wasm branch from 1d2e4ed to 8d23a04 Compare August 28, 2026 15:30
trace_processor_rpc_init() allocated a 32MB request buffer that JS wrote into
and C++ copied out of on every chunk. The tokenizer holds a standing
reservation instead and hands back the address for the next write, so nothing
is copied and it stays at one JS->Wasm call per request.

Entry points are resolved once with cwrap() instead of ccall(), which redoes
the symbol lookup and argument marshalling on every call. For a numeric
signature cwrap() returns the raw wasm export, so this is as direct as it gets:
29.6 ns -> 4.5 ns per call.

  memory64, vs the staging buffer: trace load -61.5%, queries -23.7%

addFunction() was declared as returning void; it returns a function pointer.
ccall()'s any[] hid that, cwrap()'s number[] does not.
@LalitMaganti
LalitMaganti force-pushed the dev/lalitm/zerocopy-2-wasm branch from 8d23a04 to 537bba2 Compare August 28, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants